package com.example.publishDemo.Service.Impl;


import com.example.publishDemo.Mapper.ArticleMapper;
import com.example.publishDemo.Mapper.CommentMapper;
import com.example.publishDemo.Mapper.UserMapper;
import com.example.publishDemo.Model.Comment;
import com.example.publishDemo.Model.User;
import com.example.publishDemo.Model.UserRelation;
import com.example.publishDemo.Service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Resource
    UserMapper userMapper;

    @Resource
    CommentMapper commentMapper;

    @Resource
    ArticleMapper articleMapper;

    @Override
    public List<User> userlist() {
        return userMapper.userlist();
    }

    @Override
    public int addUser(String username, String password,String gender) {
        return userMapper.addUser(username, password, gender);
    }

    @Override
    public int registe(User user) {
        return userMapper.regist(user);
    }

    @Override
    public User findOne(String username, String password) {
        return userMapper.findOne(username,password);
    }

    @Override
    public List<User> checkNameExcludingMe(String username,int u_id) {
        return userMapper.checkNameExcludingMe(username,u_id);
    }

    @Override
    public List<User> checkName(String username) {
        return userMapper.checkName(username);
    }

    @Override
    public int delUser(int id) {
        return userMapper.delUser(id);
    }

    @Override
    public User login(User user) {
        return userMapper.login(user);
    }

    @Override
    public int UnFollow(int focus_id, int focused_id) {
        return userMapper.UnFollow(focus_id,focused_id);
    }

    @Override
    public int buildRelationship(int focus_id, int focused_id) {
        return userMapper.buildRelationship(focus_id,focused_id);
    }

    @Override
    public List<UserRelation> isRelation(int focus_id, int focused_id) {
        return userMapper.isRelation(focus_id,focused_id);
    }

    @Override
    public User getUserForId(int u_id) {
        return userMapper.findById(u_id);
    }

    @Override
    public List<User> getUserFansForId(int u_id) {
        return userMapper.getUserFansForId(u_id);
    }

    @Override
    public int changUserStatus(int u_id, String userStatus) {
        return userMapper.changUserStatus(u_id,userStatus);
    }

    @Override
    public int changeUserInfo(String username, String password,int u_id) {
        return userMapper.changeUserInfo(username,password,u_id);
    }

    @Override
    public void changeUserGravatar(String picture, int u_id) {
        userMapper.changeUserGravatar(picture,u_id);
        commentMapper.changeUserGravatar(picture, u_id);
        articleMapper.changeUserGravatar(picture, u_id);
    }

    @Override
    public List<Integer> GetAllUsersOfFocusId(int u_id) {
        return userMapper.GetAllUsersOfFocusId(u_id);
    }
}
